<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // ES6声明对象简写
    // let age = 12
    // let name = "Amy"
    // //传统
    // let personal1 = { name: name, age: age }
    // console.log(personal1)
    // //ES6
    // let personal2 = { name, age }
    // console.log(personal2)

    // 1、拷贝对象
    let person1 = { name: "Amy", age: 15 }
    let someone = { ...person1 }
    console.log(someone)  //{name: "Amy", age: 15}

    // 2、合并对象
    let age = { age: 15 }
    let name = { name: "Amy" }
    let person2 = { ...age, ...name }
    console.log(person2)  //{age: 15, name: "Amy"}

    let person = {
      name: "jack",
      age: 21,
      language: ['java', 'js', 'css']
    }
    console.log(Object.keys(person))
    console.log(Object.values(person))
    console.log(Object.entries(person))

    let target = { name: 'zhangsan' };
    let source1 = { age: 24 };
    let source2 = { gender: '男' };
    //Object.assign 方法的第一个参数是目标对象，后面的参数都是源对象。
    Object.assign(target, source1, source2);
    console.log(target)//{name: 'zhangsan', age: 24, gender: '男'}
  </script>
</body>

</html>